import requests
import re
from urllib3.exceptions import InsecureRequestWarning
import datetime

# 禁用安全请求警告
Platform = "奇热"
today = datetime.date.today()  # 今天
yester = today - datetime.timedelta(days=1)


def qire():
    try:
        requests.urllib3.disable_warnings(InsecureRequestWarning)
        r = requests.session()
        url = "https://ad.qirexiaoshuo.com/index/login.html"
        data = {
            "username": "",
            "passwore": ""
        }
        rr = r.post(url=url, data=data, verify=False, timeout=15)
        aa = r.get(url="https://ad.qirexiaoshuo.com/tongji/index", verify=False, timeout=15)
        html = aa.text
        ht = html.replace('\r', '').replace('\t', '').replace('\n', '')
        date_time_list = re.findall('<tr>.*?<td>(.*?)</td>', ht)
        Amount_share_list = re.findall('<td class="orange">(.*?)</td>', ht)
        i = 0
        for y in date_time_list:
            if str(y) == str(yester):
                date_time = date_time_list[i]
                Amount_share = Amount_share_list[i]
                return date_time, Amount_share, Platform
            else:
                if i == len(date_time_list) - 1:
                    return '', 'None', Platform
                else:
                    pass
            i += 1
    except Exception:
        print("获取 奇热 数据失败")
        return '', 'None', Platform
    except ConnectionError:
        print("获取 奇热 数据 超时")
        return '', 'None', Platform